package com.qn.meta.service;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qn.common.base.BaseServiceImpl;
import com.qn.common.base.model.BasicFetchPage;
import com.qn.common.base.model.RequestPage;
import com.qn.meta.entity.FeatureBlacklist;
import com.qn.meta.mapper.FeatureBlacklistMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.Objects;
/**
 * qingniu-cloud user source analysis
 *
 * @Author: TXG
 * @Date: 2024/6/11
 * @Version V0.0.2
 */
@DubboService(version = "1.0.0")
public class FeatureBlacklistServiceImpl
        extends BaseServiceImpl<FeatureBlacklist>
        implements FeatureBlacklistService {
    @Autowired
    FeatureBlacklistMapper baseMapper;
    @Override
    public BasicFetchPage<FeatureBlacklist> getPage(RequestPage<FeatureBlacklist> rpage) {
        IPage<FeatureBlacklist> page = new Page<>(rpage.getPage(), rpage.getPageSize());
        IPage<FeatureBlacklist> pageList = baseMapper.getPage(page, rpage.getWhere());
        return new BasicFetchPage(pageList.getTotal(), pageList.getRecords());
    }

    @Override
    public void saves(FeatureBlacklist model) throws Exception {
        if (Objects.isNull(model.getId())) {
            model.setUpdTime(new Date());
            baseMapper.insert(model);
        } else {
            model.setUpdTime(new Date());
            baseMapper.updateById(model);
        }
    }

    @Override
    public void del(Integer id) {
        baseMapper.deleteById(id);
    }
}